package com.zhangxiaofanfan.hotcode.first;

import java.util.Arrays;

/**
 * <a href="https://leetcode.cn/problems/unique-paths/description/?envType=study-plan-v2&envId=top-100-liked">62. 不同路径</a>
 *
 * @date 2024-07-13 03:14:13
 * @author zhangxiaofanfan
 */
public class HotCode091 {
    public static void main(String[] args) {
        HotCode091 hotCode = new HotCode091();
        System.out.println(hotCode.uniquePaths(3, 7));
    }

    public int uniquePaths(int m, int n) {
        int[][] dp = new int[m][n];
        Arrays.fill(dp[0], 1);
        for (int i = 0; i < m; i++) {
            dp[i][0] = 1;
        }
        for (int rowIndex = 1, colIndex; rowIndex < m; rowIndex++) {
            for (colIndex = 1; colIndex < n; colIndex++) {
                dp[rowIndex][colIndex] = dp[rowIndex - 1][colIndex] + dp[rowIndex][colIndex - 1];
            }
        }
        return dp[m - 1][n - 1];
    }
}